import java.util.Arrays;
import java.util.Locale;

public class Text {

    public static void main(String[] args) {
        StringBuilder b1 = new StringBuilder("hello");
        String b = b1.toString();
        b1 = b1.append(b);
    }

    public static void main7(String[] args) {
        String s = " helw wlksnd wlknfdwl  wkfd ";
        //字符拆分
        System.out.println(s.length());
        String[] neo = s.split(" ");
        System.out.println(Arrays.toString(neo));

        String str = "191.12.12";
        String[] n = str.split("\\.");  //按字符划分加\\
        System.out.println(Arrays.toString(n));

        //字符串截取
        System.out.println(s.substring(3));
        System.out.println(s);
        System.out.println(s.trim());
    }

    public static void main6(String[] args) {
        String s = "hello";
        System.out.println(s.replaceAll("l","w"));
        System.out.println(s.replaceFirst("l","w"));
    }

    public static void main5(String[] args) {
        //大小写转换
        String s1 = "hello";
        String s2 = "HELLO";
        System.out.println(s1.toUpperCase());
        System.out.println(s2.toLowerCase());

        //字符串转数组
        String s = "hello";
        char[] ch = s.toCharArray();
        System.out.println(ch.length);
        System.out.println(Arrays.toString(ch));
        String str = new String(ch);
        System.out.println(str);

        //
        String s4 = String.format("%d-%d-%dawsdwasdawd", 2019, 9,14);
        System.out.println(s4);

    }

    public static void main4(String[] args) {
        //字符串转换
        String s1 = String.valueOf('a');
        String s2 = String.valueOf(11);
        String s3 = String.valueOf(12.5);
        double a = 12.5;
        float b = 12.5F;
        String s4 = String.valueOf(true);
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);

        //字符串转数字
        int a1 = Integer.parseInt("123");
        double a2 = Double.parseDouble("12.1");


    }

    public static void main3(String[] args) {

        String str = "nihaoa hellpo word world";
        System.out.println(str.charAt(3));
        System.out.println(str.indexOf('a'));
        System.out.println(str.indexOf("hell"));
        System.out.println(str.indexOf('a', 4));
        System.out.println(str.indexOf("hao",2));

        System.out.println(str.lastIndexOf('w'));
        System.out.println(str.lastIndexOf('a'));
        System.out.println(str.lastIndexOf('w',15));


    }

    public static void main2(String[] args) {
        //字符串比较
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("Hello");
        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
        System.out.println(s1.equals(s2));

        //compareTo  返回int类型
        System.out.println(s1.compareTo(s3));
        //忽略大小写
        System.out.println(s1.compareToIgnoreCase(s3));
    }

    public static void main1(String[] args) {
        //字符串构造
        String s1 = "hello word";
        String s2 = new String("asdasd");
        char[] chars = new char[]{'1','3','f'};
        String s3 = new String(chars);
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);


    }
}
